/*
 * xregex.cpp
 *
 *  Created on: Aug 26, 2011
 *      Author: lindenb
 */

#include "xexception.h"
#include "xregex.h"

using namespace std;


Pattern::Pattern()
    {

    }

Pattern::~Pattern()
    {
    if(preg!=NULL) ::regfree(&preg);
    }
Pattern* Pattern::compile(const char *regex, int cflags)
    {
    Pattern* p=new Pattern;
    if(::regcomp(&(p->preg),regex,cflags)!=0)
	{
	THROW("Cannot compile pattern " << regex);
	}
    return p;
    }
